//package com.example.demo.obs;
//
//import java.io.ByteArrayInputStream;
//import java.io.InputStream;
//
//import com.obs.services.ObsClient;
//import com.obs.services.ObsConfiguration;
//import com.obs.services.model.AccessControlList;
//import com.obs.services.model.PutObjectRequest;
//import com.obs.services.model.S3Object;
//public class ObsServerClient {
//
//	
//	private static ObsClient obsClient;
//	
//	private ObsServerClient(){
//		
//	}
//	
//	private static ObsClient getObsClient() {
//        if (obsClient == null) {
//            // 初始化
//            init();
//        }
//        return obsClient;
//    } 
//
//	private static void init(){
//		
//			ObsConfiguration config = new ObsConfiguration();
//	        config.setSocketTimeout(30000);
//	        config.setConnectionTimeout(10000);
//	        config.setEndPoint(ObsConfig.END_POINT);
//	        config.setMaxConnections(1000);
//	        config.setSockeReadBufferSize(8192);
//	        config.setSocketWriteBufferSize(8192);
//	        config.setVerifyResponseContentType(false);
//	        config.setUploadStreamRetryBufferSize(1024*100);
//	        config.setHttpsOnly(false);
//	        config.setDisableDnsBucket(true);
//	        config.setSignatString("v2");
//	        config.setDefaultBucketLocation("cn-north-1");
//			// 创建ObsClient实例
//	        obsClient= new ObsClient(ObsConfig.AK, ObsConfig.SK, config);
//	        //创建文件夹
//	        createdObsFolder(obsClient);
////		S3BucketCors cors = new S3BucketCors();
////		List<BucketCorsRule> rules = new ArrayList<BucketCorsRule>();
////		BucketCorsRule rule = new BucketCorsRule();
////
////		ArrayList<String> allowedOrigin = new ArrayList<String>();
////		// 指定允许跨域请求的来源
////		allowedOrigin.add( "http://www.a.com"); 
////		allowedOrigin.add( "http://www.b.com"); 
////		rule.setAllowedOrigin(allowedOrigin);
////
////		ArrayList<String> allowedMethod = new ArrayList<String>();
////		// 指定允许的跨域请求方法(GET/PUT/DELETE/POST/HEAD)
////		allowedMethod.add("GET");   
////		allowedMethod.add("HEAD");
////		allowedMethod.add("PUT");   
////		rule.setAllowedMethod(allowedMethod);
////
////		ArrayList<String> allowedHeader = new ArrayList<String>();
////		// 控制在OPTIONS预取指令中Access-Control-Request-Headers头中指定的header是否被允许使用
////		allowedHeader.add("x-obs-header"); 
////		rule.setAllowedHeader(allowedHeader);
////
////		ArrayList<String> exposeHeader = new ArrayList<String>();
////		// 指定允许用户从应用程序中访问的header
////		exposeHeader.add("x-obs-expose-header");
////		rule.setExposeHeader(exposeHeader);
////
////		// 指定浏览器对特定资源的预取(OPTIONS)请求返回结果的缓存时间,单位为秒
////		rule.setMaxAgeSecond(10);
////		rules.add(rule);
////		cors.setRules(rules);
////
////		obsClient.setBucketCors("bucketname", cors);
//	}
//	
//	private static void createdObsFolder(ObsClient obsClient){
//		obsClient.putObject(ObsConfig.BUCKET_NAME, ObsConfig.FLODER_FILE_NAME, new ByteArrayInputStream(new byte[0]));
////		obsClient.putObject(ObsConfig.BUCKET_NAME, ObsConfig.FLODER_YUE_NAME, new ByteArrayInputStream(new byte[0]));
////		obsClient.putObject(ObsConfig.BUCKET_NAME, ObsConfig.FLODER_DOCUMENT_NAME, new ByteArrayInputStream(new byte[0]));
//	}
//	
//	public static void putObject(String objectKey,InputStream inputStream){
//		//访问权限
//        PutObjectRequest request = new PutObjectRequest();
//        request.setBucketName(ObsConfig.BUCKET_NAME);
//        request.setObjectKey(objectKey);
//        request.setInput(inputStream);
//        //设置对象访问权限为公共读
//        request.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ);
//        getObsClient().putObject(request);
//	}
//	
//	public static S3Object getObject(String objectKey){
//		return getObsClient().getObject(ObsConfig.BUCKET_NAME, objectKey);
//	}
//	
//}
